﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace MyUtility
{
    public partial class MoveCirclePage : PhoneApplicationPage
    {
        public MoveCirclePage()
        {
            InitializeComponent();
			//drawCircle();
			//createStoryBoard();
			this.Loaded +=new System.Windows.RoutedEventHandler(MoveCirclePage_Loaded);
        }
		
		Canvas layOutRoot = new Canvas();
		Ellipse circle = new Ellipse();
		Storyboard sb = new Storyboard();
		
		public void drawCircle(){
			
			
			circle.Height = 200;
			circle.Width  = 200;
			
			circle.SetValue(Canvas.LeftProperty,50.0);
			circle.SetValue(Canvas.TopProperty,50.0);
			
			SolidColorBrush colorBrush = new SolidColorBrush(Colors.Orange);
			circle.Fill = colorBrush;
			//<canvas><Ellipse x:Name="circlr" .../></Canvas>
			layOutRoot.Children.Add(circle);
			
			//<PhoneApplicationPage><Canvas>.. </Canvas></PhoneApplicationPage>
			this.Content = layOutRoot;
		}
		public void createStoryBoard(){
			//<StroryBoard><DoubleAnimation/></StoryBoard>
			DoubleAnimation animateCanvasTop = new DoubleAnimation();
			animateCanvasTop.From = 50.0;
			animateCanvasTop.To = 300.0;
			animateCanvasTop.Duration = new Duration(TimeSpan.FromSeconds(2.0));
			Storyboard.SetTarget(animateCanvasTop,circle);
			Storyboard.SetTargetProperty(animateCanvasTop,new PropertyPath("(Canvas.Top)"));
			//Object & Property?
			sb.AutoReverse = true;
			sb.RepeatBehavior = new RepeatBehavior(10.0);
			sb.Children.Add(animateCanvasTop);
			this.Resources.Add("sb",sb);
		}

		private void MoveCirclePage_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
			// TODO: Add event handler implementation here.
			drawCircle();
			createStoryBoard();
			sb.Begin();
		}
    }
}
